import request from "@/utils/request";
import { IKeyword } from "./type";

export function keywordsApi(queryParams: IKeyword): Promise<ResType> {
    return request({
        url: "/ProductApi/ProductList",
        method: "get",
        params: queryParams,
    });
}

//产品导入按钮
export function importProductApi(queryParams?: any): Promise<ResType> {
    return request({
        url: "/ProductApi/GetList",
        method: "get",
        params: queryParams,
    });
}
//产品导入搜索
export function searchProductApi(queryParams: any): Promise<ResType> {
    return request({
        url: "/ProductApi/GetList",
        method: "get",
        params: queryParams,
    });
}
//产品导入批量
export function batchImportProductApi(data: any): Promise<ResType> {
    return request({
        url: "/ProductApi/Dr",
        method: "post",
        data: data,
    });
}

//获取产品详情
export function getProductDetailApi(Params: any): Promise<ResType> {
    return request({
        url: "/ProductApi/ProDetail",
        method: "get",
        params: Params,
    });
}

//删除产品
export function deleteProductApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("id", data.id);
    return request({
        url: "/ProductApi/DeleteProduct",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//批量删除产品
export function batchDeleteProductApi(data: any): Promise<ResType> {
    return request({
        url: "/ProductApi/DeleteProducts",
        method: "post",
        data: data,
    });
}

//上架
export function upProductApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("id", data.id);
    return request({
        url: "/ProductApi/GetInfokey",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//产品上架
export function UpProductApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("id", data.id);
    return request({
        url: "/ProductApi/PutonProduct",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//批量产品上架
export function batchUpProductApi(data: any): Promise<ResType> {
    return request({
        url: "/ProductApi/PutonProductList",
        method: "post",
        data: data,
    });
}

//获取推广中的产品
export function getPromotionProductApi(queryParams: any): Promise<ResType> {
    return request({
        url: "/ProductApi/PromoteProductList",
        method: "post",
        params: queryParams,
    });
}

//产品下架
export function downProductApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("id", data.id);
    return request({
        url: "/ProductApi/TakenOffProduct",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//批量产品下架
export function batchDownProductApi(data: any): Promise<ResType> {
    return request({
        url: "/ProductApi/TakenOffProductList",
        method: "post",
        data: data,
    });
}

//添加产品
export function addProductApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("InforTitle", data.InforTitle);
    formData.append("InforModel", data.InforModel);
    formData.append("BrandName", data.BrandName);
    formData.append("InforOrigin", data.InforOrigin);
    formData.append("Description", data.Description);
    formData.append("InforPicTure", data.InforPicTure);
    formData.append("InforPicTure2", data.InforPicTure2);
    formData.append("InforPicTure3", data.InforPicTure3);
    formData.append("InforPicTure4", data.InforPicTure4);
    formData.append("InforPicTure5", data.InforPicTure5);
    formData.append("InforContent", data.InforContent);
    formData.append("Keyword", data.Keyword);
    formData.append("LKeyword", data.LKeyword);
    formData.append("RKeyword", data.RKeyword);
    formData.append("CusKeyword", data.CusKeyword);
    formData.append("Region", data.Region);
    return request({
        url: "/ProductApi/AddProduct",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//图片上传
export function uploadImgApi(data: any): Promise<ResType> {
    return request({
        url: "/ProductApi/FileUploadimg",
        method: "post",
        data: data,
    });
}

//获取产品词
export function getProductWordsApi(): Promise<ResType> {
    return request({
        url: "/ProductApi/AddProductView",
        method: "get",
    });
}

//编辑器里内容检测
export function editorContentCheckApi(data: {
    content: string;
}): Promise<ResType> {
    return request({
        url: "/ProductApi/verify",
        method: "post",
        data: data,
    });
}

//必删词检测
export function deleteWordsCheckApi(data: {
    txt: string;
    content: string;
}): Promise<ResType> {
    return request({
        url: "/ProductApi/del",
        method: "post",
        data: data,
    });
}

//敏感词检测
export function sensitiveWordsCheckApi(data: {
    txt: string;
    content: string;
}): Promise<ResType> {
    return request({
        url: "/ProductApi/nodel",
        method: "post",
        data: data,
    });
}

//产品修改
export function editProductApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("id", data.id);
    formData.append("InforTitle", data.InforTitle);
    formData.append("InforModel", data.InforModel);
    formData.append("BrandName", data.BrandName);
    formData.append("InforOrigin", data.InforOrigin);
    formData.append("Description", data.Description);
    formData.append("InforPicTure", data.InforPicTure);
    formData.append("InforPicTure2", data.InforPicTure2);
    formData.append("InforPicTure3", data.InforPicTure3);
    formData.append("InforPicTure4", data.InforPicTure4);
    formData.append("InforPicTure5", data.InforPicTure5);
    formData.append("InforContent", data.InforContent);
    formData.append("Keyword", data.Keyword);
    formData.append("LKeyword", data.LKeyword);
    formData.append("RKeyword", data.RKeyword);
    formData.append("CusKeyword", data.CusKeyword);
    formData.append("Region", data.Region);
    formData.append("DeleteKeyword", data.DeleteKeyword);
    return request({
        url: "/ProductApi/UpdateProduct",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//检测关键词是否存在
export function checkKeywordApi(Params: { Keyword: string }) {
    return request({
        url: "/ProductApi/IsKeyword",
        method: "get",
        params: Params,
    });
}

//获取修改产品详细
export function getUpdateProductApi(Params: any) {
    return request({
        url: "/ProductApi/UpdateProductView",
        method: "get",
        params: Params,
    });
}

//查看公司资料
export function getCompanyInfoApi(): Promise<ResType> {
    return request({
        url: "/AdminApi/Company",
        method: "get",
    });
}

//公司资料修改
export function updateCompanyInfoApi(data: any): Promise<ResType> {
    return request({
        url: "/AdminApi/SaveCompany",
        method: "post",
        data: data,
    });
}

//获取服务管理
export function getServiceApi(): Promise<ResType> {
    return request({
        url: "/AdminApi/ServiceLogShow",
        method: "get",
    });
}

//排名报表
export function getReportApi(Params: any): Promise<ResType> {
    return request({
        url: "/ProductApi/Ranking",
        method: "get",
        params: Params,
    });
}

//查看快照
export function getSnapshotApi(Params: any): Promise<ResType> {
    return request({
        url: "/ProductApi/showhtml",
        method: "get",
        params: Params,
    });
}

//导出报表
export function exportReportApi(): Promise<ResType> {
    return request({
        url: "/ProductApi/userForm",
        method: "get",
    });
}

//数据报表
export function getDataReportApi(): Promise<ResType> {
    return request({
        url: "/ProductApi/Report",
        method: "get",
    });
}

//获取关键词排名
export function getKeywordRankApi(Params: { eq: number }): Promise<ResType> {
    return request({
        url: "/ProductApi/KeywordsChart",
        method: "get",
        params: Params,
    });
}

//获取询盘私信
export function getInquiryMessageApi(): Promise<ResType> {
    return request({
        url: "/ProductApi/Order",
        method: "get",
    });
}

//获取文章列表
export function getArticleListApi(Params: {
    state: number;
    isUpperShelf: number;
    orderkey: number;
    pn: number;
    pagesize: number;
}): Promise<ResType> {
    return request({
        url: "/ArticleApi/ArticleList",
        method: "get",
        params: Params,
    });
}

//文章导入按钮
export function importArticleApi(): Promise<ResType> {
    return request({
        url: "/ArticleApi/GetList",
        method: "get",
    });
}

//文章导入搜索
export function searchArticleApi(queryParams: {
    pn: number;
    pagesize: number;
    tk: string;
}): Promise<ResType> {
    return request({
        url: "/ArticleApi/GetList",
        method: "get",
        params: queryParams,
    });
}
//文章导入批量
export function batchImportArticleApi(data: any): Promise<ResType> {
    return request({
        url: "/ArticleApi/Dr",
        method: "post",
        data: data,
    });
}

//获取文章详细
export function getArticleDetailApi(Params: { id: number }): Promise<ResType> {
    return request({
        url: "/ArticleApi/ArticleDetail",
        method: "get",
        params: Params,
    });
}

//删除文章
export function deleteArticleApi(data: { id: number }): Promise<ResType> {
    const formData = new FormData();
    formData.append("id", data.id.toString());
    return request({
        url: "/ArticleApi/DeleteArticle",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//获取文章关键词
export function getArticleKeywordsApi(Params: {
    id: number;
    pid:number;
}): Promise<ResType> {
    return request({
        url: "/ArticleApi/GetKeyword",
        method: "get",
        params: Params,
    });
}

//获取推广中的技术文章
export function getPromotionArticleApi(): Promise<ResType> {
    return request({
        url: "/ArticleApi/PromotionArticleList",
        method: "get"
    });
}

//撤销推广
export function cancelPromotionArticleApi(Params: {
    id: number;
}): Promise<ResType> {
    return request({
        url: "/ArticleApi/UndershelfArticle",
        method: "get",
        params: Params,
    });
}

//文章推广
export function promotionArticleApi(Params: {
    id: number;
    checkqx1:string
}): Promise<ResType> {
    return request({
        url: "/ArticleApi/UpdateProStatus",
        method: "get",
        params: Params,
    });
}

//批量文章推广
export function promotionArticleBatchApi(Params: {
    ids: string;
    checkqx1:string
}): Promise<ResType> {
    return request({
        url: "/ArticleApi/UpdateProStatusAll",
        method: "get",
        params: Params,
    });
}

//已选中推广站点
export function promotionSiteApi(): Promise<ResType> {
    return request({
        url: "/ArticleApi/GetDomainlist",
        method: "get"
    });
}

//检测主关键词是否存在
export function checkMainKeywordApi(Params: {
    Keyword: string;
}): Promise<ResType> {
    return request({
        url: "/ArticleApi/IsKeyword",
        method: "get",
        params: Params,
    });
}

//文章关键词提交
export function articleKeywordSubmitApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("ID", data.id.toString());
    formData.append("PID", data.pid.toString());
    formData.append("zkey", data.zkey);
    formData.append("tkey", data.tkey);
    return request({
        url: "/ArticleApi/SetKeyword",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//添加文章获取所在地区
export function getArticleAreaApi(): Promise<ResType> {
    return request({
        url: "/ArticleApi/AddArticleView",
        method: "get",
    });
}

//检测文章详细内容
export function checkArticleContentApi(data: {
    content: string;
}): Promise<ResType> {
    return request({
        url: "/ArticleApi/verify",
        method: "post",
        data: data
    });
}

//添加文章
export function addArticleApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("Title", data.Title);
    formData.append("Province", data.Province);
    formData.append("City", data.City);
    formData.append("Detail", data.Detail);
    formData.append("Reprint", data.Reprint);
    formData.append("Keyword", data.Keyword);
    formData.append("LKeyword", data.LKeyword);

    return request({
        url: "/ArticleApi/AddArticle",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

export function checkNameContent(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("txt", data.txt);
    formData.append("Content", data.Content);

    return request({
        url: "/ArticleApi/del",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}

//修改文章
export function editArticleApi(data: any): Promise<ResType> {
    const formData = new FormData();
    formData.append("ID", data.ID);
    formData.append("Title", data.Title);
    formData.append("Province", data.Province);
    formData.append("City", data.City);
    formData.append("Detail", data.Detail);
    formData.append("Reprint", data.Reprint);
    formData.append("Keyword", data.Keyword);
    formData.append("LKeyword", data.LKeyword);

    return request({
        url: "/ArticleApi/UpdateArticle",
        method: "post",
        data: formData,
        headers: {
            "Content-Type": "multipart/form-data",
        },
    });
}
